var streetLayer;

function loadRegion() {
  if (streetLayer) {
    map.removeLayer(streetLayer, true);
  }
  streetLayer = new mars3d.layer.GeoJsonLayer({
    url: "https://wckj2020.obs.cn-south-1.myhuaweicloud.com:443/wckj/screen5-1/example/res/data/bjzone.json",
    // url: "../example/res/data/newStreet.json",
    mask: false, //标识为遮罩层【重点参数】
    name: "街道数据",
    symbol: {
      type: "polygon",
      styleOptions: {
        fill: false,
        // color: "rgb(2,26,79)",
        opacity: 0.7,
        outline: true,
        outlineColor: "#F8F8FF",
        outlineWidth: 3,
        outlineOpacity: 0.8,
        clampToGround: true,

        label: {
          //面中心点，显示文字的配置
          text: "{SNAME}", //对应的属性名称
          opacity: 1,
          font_size: 16,
          color: "#ffffff",
          visibleDepth: false,

          font_family: "微软雅黑",
          outline: true,
          outlineColor: "#00000",
          outlineWidth: 5,

          background: false,
          backgroundColor: "#000000",
          backgroundOpacity: 0.1,

          font_weight: "bolder",
          font_style: "normal",

          // hasPixelOffset: true,
          // pixelOffsetY: -30,

          scaleByDistance: true,
          scaleByDistance_far: 20000000,
          scaleByDistance_farValue: 0.1,
          scaleByDistance_near: 1000,
          scaleByDistance_nearValue: 1,

          distanceDisplayCondition: true,
          distanceDisplayCondition_far: 20000,
          distanceDisplayCondition_near: 0,
        },
      },
      // callback: function (attr, styleOpt) {
      //   for (let i in streetHwIndex) {
      //     if (attr.STID == streetHwIndex[i].STID) {
      //       if (streetHwIndex[i].WORKLIFE_T1 <= 2) {
      //         styleOpt.color = "rgb(38,192,34)";
      //       } else if (0 < streetHwIndex[i].WORKLIFE_T1 && streetHwIndex[i].WORKLIFE_T1 <= 5) {
      //         styleOpt.color = "rgb(154,252,43)";
      //       } else if (5 < streetHwIndex[i].WORKLIFE_T1 && streetHwIndex[i].WORKLIFE_T1 <= 10) {
      //         styleOpt.color = "rgb(252,255,44)";
      //       } else if (10 < streetHwIndex[i].WORKLIFE_T1 && streetHwIndex[i].WORKLIFE_T1 <= 20) {
      //         styleOpt.color = "rgb(245,149,29)";
      //       } else if (20 < streetHwIndex[i].WORKLIFE_T1 && streetHwIndex[i].WORKLIFE_T1 <= 40) {
      //         styleOpt.color = "rgb(250,209,39)";
      //       } else {
      //         styleOpt.color = "rgb(232,4,29)";
      //       }
      //     }
      //   }

      // },
    },
  });
  // map.addLayer(streetLayer);
}
